

<body>

    <div class="warp h">
        <!--header-->
        <header class="hd br">
            <a href="<?php echo $base_url?>home/order/userorders" class="l-icon only-icon">
            <i class="iconfont icon-left1"></i>
        </a>
            <p class="tit2">
                确认订单
            </p>
        </header>

         <div class="surplustime-box">
            <p class="tit">待付款 </p>
            <p class="msg">
            还剩<span class="time"></span>，订单将被取消
                
            </p>
        </div>
 

        <div class="order-address sel">
            <a href="javascript:void(0);">
                <div class="l">
                    <i class="iconfont icon-shouhuodizhi"></i>
                </div>
                <div class="r">
                    <p>收货人：<?php echo $data['username'];?> <?php echo $data['mobile'];?></p>
                    <p>收货地址：<?php echo $data['address'];?></p>
                </div>

                <!-- <i class="icon iconfont icon-left"></i> -->

            </a>
        </div>

        <div class="pay-bar border-none">
            <ul>
                <li class="tit">支付方式</li>
              
                <?php if(empty($openid)): ?>
                <li>
                    <a href="#11" class="sel-pay">
                        <span class="l"><i class="iconfont icon-zhifu"></i>支付宝</span>
                        <span class="radio">
                            <i class="iconfont myicon icon-gou" data-paytype="3"></i>
                        </span>
                    </a>
                </li>
                <?php else: ?>
                  <li>
                    <a href="#11"  class="sel-pay">
                        <span class="l"><i class="iconfont icon-ananzuiconv267"></i>微信</span>
                        <span class="radio">
                            <i class="iconfont myicon icon-gou" data-paytype="2"></i>
                        </span>
                    </a>
                </li>
                <?php endif; ?>
            </ul>
        </div>

		<div class="line-box"></div>
        <ul class="order-list type03">
            
            <?php foreach ($data['detail'] as $k => $v) :?>
            <li>
                <!-- <div class="line-box"></div> -->
                <div class="order-itme">
                  <div class="order-box-1">
                        <div class="l">
                            <img src="<?php echo $base_url.$v['img_path'];?>" alt="<?php echo $v['img_name'];?>">
                        </div>
                        <div class="r">
                            <p class="tit">
                                <?php echo $v['goods_name']?>
                            </p>
                            <!-- <p class="ms-tit" style="display: none;">
                                颜色分类：黄色；
                            </p> -->
                            <p class="price-num">
                                <span>¥</span><?php echo $v['price'];?>
                                <span class="num">x<?php echo $v['amount'];?></span>
                            </p>
                        </div>
                    </div>
                
            </li>          
            <?php endforeach; ?>

            <li>
                <div class="order-itme">
                    <!-- <div class="line-box"></div> -->
                        <div class="order-box-2">
                            <span class="r">
                                快递&nbsp;&nbsp;&nbsp;<span>免邮</span>
                            </span>
                            <span class="l">
                                配送方式
                            </span>
                        </div>
                        <div class="order-box-2">
                            <span class="tit">买家备注：</span>
							<span class="leave_txt">
								<?php echo $data['leave']; ?>							
							</span>
                            <!--<input class="remarks" readonly type="text" placeholder="选填，对本次交易订单的说明" value="<?php echo $data['leave']; ?>">-->
                        </div>
                </div>
            </li>
        </ul>


        <div class="line-box"></div>

        <div class="pd-box"></div>
        <div class="sub-order-ft">
            <div class="pricesum">
                合计: <span>¥<?php echo $data['price'];?></span>
            </div>
            <a class="sub-btn" id="submit">
                支付<!-- &nbsp;&nbsp;<span class="time">30:00</span> -->

            </a>
        </div>



    </div>
    <input id='order_id' type="hidden" value="<?php echo $order_id; ?>">
    <input id='left_time' type="hidden" value="<?php echo $data['left_time']; ?>">
    
    <script src="/static/dist/js/base.js"></script>

    <script>
        // 矫正rem
        function correctrem() {
            var rem_full_width = $("<div id='rem-test' style='width:7.5rem'></div>").appendTo($('body')).width();
            var device_width = Math.min(document.documentElement.clientWidth, 640);
            if (rem_full_width !== device_width) {
                document.documentElement.style.fontSize = (device_width / 7.5) * (device_width / rem_full_width) + 'px';
            }
            $('#rem-test').remove();
        }
        correctrem();
        $(function () {
             $(".sel-pay").hammer().bind("tap", function (ev) {
                 var $this_i = $(this).find('.radio i');   
                 console.log($this_i.hasClass("icon-gou"))              
                 if(!$this_i.hasClass("icon-gou")){
                    $(".radio i").removeClass("icon-gou");
                    $this_i.addClass("icon-gou");
                 }
                  
             });

             $('#submit').on('click', function(){
                var order_id = $('#order_id').val();
                payType = $('.icon-gou').attr('data-paytype');
                $.post("<?php echo $base_url; ?>home/order/repay", 
                        { order_id:order_id, paytype:payType},  
                       function(data){  
                         if(data.errcode != 0)
                         {
                            alert(data.errmsg);
                            if(data.errcode == 4)
                            {
                                //订单已支付
                                location.reload();
                            }
                         } 
                         else
                         {  
                            if(payType == 3){
                                    $.post("<?php echo $base_url; ?>ajax/payment/zhifbscpay",{order_id:order_id},function(result){
                                        window.location.href = result.code_url;
                                    },"json");return;
                            }
                            if(payType == 2){
                                $.post("<?php echo $base_url; ?>ajax/payment/wxinoppay",{order_id:order_id},function(result){
                                    window.location.href = 'https://pay.swiftpass.cn/pay/jspay?token_id='+result.token_id+'&showwxtitle=1';
                                },"json");return;
                            }
                            
                         }
                       }, 
                        "json");  
             });


			var $timeSpan = $('.surplustime-box').find('.time')
			function renderTimeTop(minute,second){				
				var secondStr = second?second+'秒':'';
				var minuteStr = minute?minute+'分':'';
				
				$timeSpan.text(minuteStr + secondStr);
			}

			 //30倒计时
			var left_time_y = parseInt($("#left_time").val()) || 0;
			var left_time = left_time_y;
			var timer = null;
			function loopTime(){
				if(left_time_y<0){
					return;
				}			
				timer = setTimeout(function() {
					left_time--;
					if(left_time<=0){
						location.reload();
						clearTimeout(timer);
					}
					// renderTimeTop(parseInt(left_time/60));
					var currentTime = formatDataObj(left_time);					
					renderTimeTop(currentTime.minute,currentTime.second);
					loopTime();					
				}, 1000);
			}
			loopTime();

			var currentTime = formatDataObj(left_time)			
			renderTimeTop(currentTime.minute,currentTime.second);
			function formatDataObj(second){
				var minute = parseInt(second/60)				
				var second = parseInt(second%60)
				return {
					minute:minute,
					second:second
				}
			}


        })



		
    </script>

</body>

</html>
